sound_pool object
This method checks to see whether a sound is playing in a given slot.
bool sound_is_playing(int slot)
Parameters:
slot
The slot of a sound, as returned by one of the play methods.
Return value:
True if the sound assigned to the given slot is playing, false otherwise.
Remarks:
Please note that the sound will report as not playing if it is either closed or out of earshot. To check whether a sound exists, use the sound_is_active method.
This is useful if you want to perform another action if a sound is not playing.
Please note: When dealing with sound slots, be sure that you set the persistent flag to true for all non-looping sounds when you first create them. If you fail to do this, manipulating a sound in any way by use of its slot number can have unpredictable results. This is because the sound pool automatically cleans up any sound that has finished playing and that is not set to be persistent, with the result that the slot that was returned on creation is no longer invalid and may, in the worst case scenario, refer to a completely different sound.
Example:
#include "sound_pool.bgt"
sound_pool sounds;
void main()
{
sounds.max_distance=70;
int slot=sounds.play_1d("sounds/test.wav", 0, 20, true);
if(sounds.sound_is_playing(slot))
{
alert("information", "slot "+slot+" is currently playing.");
}
else
{
alert("information", "slot "+slot+" is not currently playing.");
}
}